#include <event2/event.h>
#include <stdio.h>


struct event *ev;
static int cnCnt = 0;
static void cb(int sock, short which, void *arg) {
        event_active(ev, EV_WRITE, 0);
        printf("cb%d \r\n", cnCnt++);
}

int main(int argc, char **argv) {
        struct event_config *cfg = event_config_new();
        /* Run at most 16 callbacks before checking for other events. */
        event_config_set_max_dispatch_interval(cfg, NULL, 16, 0);
        struct event_base *base = event_base_new_with_config(cfg);
        ev = event_new(base, -1, EV_PERSIST | EV_READ, cb, NULL);

        event_add(ev, NULL);

        event_active(ev, EV_WRITE, 0);

        event_base_loop(base, 0);

        return 0;
}

